package com.huabo.system.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hbfk.util.JsonBean;
import com.huabo.system.service.YinMaiBusinessService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
@Api(value = "引迈对接Controller", tags = {"引迈的对接Controoler"})
@RequestMapping("/yinMai")
public class YinMaiDockingController {

	
	@Resource
	public YinMaiBusinessService yinMaiBusinessService;
	
	@RequestMapping(value = "/singleSign", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
    @ApiParam("单点登录访问获取token等用户信息")
    public JsonBean singleSignMothed(HttpServletRequest reques,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token) throws Exception {
        return this.yinMaiBusinessService.singleSignMothed(token);
    }
	
	
	
	@RequestMapping(value = "/synchronizeOrgInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
    @ApiParam("批量同步组织信息")
    public JsonBean synchronizeOrgInfo(HttpServletRequest reques,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="orgId",value="同步公司组织信息",required=false) @RequestParam(value = "orgId", required = false) Integer orgId) throws Exception {
        return this.yinMaiBusinessService.synchronizeOrgInfo(token,orgId);
    }
	
	@RequestMapping(value = "/synchronizeRoleInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
    @ApiParam("批量同步角色信息-需要先同步组织")
    public JsonBean synchronizeRoleInfo(HttpServletRequest reques,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="orgId",value="同步公司Id",required=false) @RequestParam(value = "orgId", required = false) Integer orgId) throws Exception {
        return this.yinMaiBusinessService.synchronizeRoleInfo(token,orgId);
    }
	
	@RequestMapping(value = "/synchronizeStaffInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
    @ApiParam("批量同步用户信息-需要先同步组织，角色")
    public JsonBean synchronizeStaffInfo(HttpServletRequest reques,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="orgId",value="同步公司组织信息",required=true) @RequestParam(value = "orgId", required = true) Integer orgId) throws Exception {
        return this.yinMaiBusinessService.synchronizeStaffInfo(token,orgId);
    }
	
}
